package com.mojo.collection.list;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

/**
 * @author Sewell
 * @version 1.0
 * @date 2021/8/12 14:04
 */
public class ArrayList1 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(4);
        list.add(3);
        list.add(2, 11);
        Collections.sort(list);
        list.sort((o1, o2) -> o2 - o1);
        for (Object o : list) {
            //有序add
            System.out.println(o);
        }
        //手动扩容，减少扩容次数
        list.ensureCapacity(100);
        //Iterator<Integer> iterator = list.iterator();
        //while (iterator.hasNext()) {
        //    Integer next = iterator.next();
        //    iterator.remove();
        //}

    }
}
